/**
 * Created with  SublimeText
 * @Author:      Lyle
 * @DateTime:    2016-12-21 22:17:32
 * @Description: 
 */

import React, { Component, PropTypes } from 'react'
import RockTree from '../modules/RockTree/RockTree'
import Config from '../../config'

class Center extends Component {

    constructor(props) {
        super(props);
    }

    render() {

        console.log(20, this.props.params.childModuleName);

        let Child, obj = Object.assign({}, this.props),
            data = Config.treeData,
            childModuleName = this.props.params.childModuleName;

        try {
            Child = require('../containers/' + childModuleName).default;
        } catch (e) {
            console.log('Cannot find childModule: ' + childModuleName);
            Child = require('../containers/Error').default;
            obj.param = '404';
        }

        return (
            <div id='center' className='module'>
                <div className='top'>
                    <div className='logo'> <span>ROCK</span><span>ADMIN</span> </div>
                </div>
                <div className='body'>
                    <div className='left'>
                        <RockTree data = {data}  {...this.props} ></RockTree>
                    </div>
                    <div className='right'>
                        <Child {...obj}/>
                    </div>
                </div>
            </div>

        )
    }
}

export default Center
